<!DOCTYPE html>
<html lang="en">
#parse('base/head.html')
<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="fp-framework main-content padding-12-20">
        <div class="main-content-inner">
            <div class="page-content">
				<div class="hidden" >
				</div>
                <div class="row">
                    
                    <div class="col-sm-12">
						<div class="row col-md-12 fp-toolbar fpxmList" >
							<button type="button" id="projectAddBtn"  class="btn btn-sm btn-primary pull-left " ><span class="ace-icon fa fa-plus icon-on-right"></span>新增</button>
							<select class="chosen-select form-control" id="form-field-project-type" data-placeholder="项目分类">
								<option value="">全部</option>
								#foreach($projectTypePO in $projectTypeList)
								<option value="$!{projectTypePO.dataKey}">$!{projectTypePO.dataName}</option>
								#end
							</select>
							<div class="input-group" >
								<input type="text" class="form-control search-query" id="form-field-project-name" placeholder="项目名称" >
								<span class="input-group-btn">
									<button type="button" id="projectSearchBtn" class="btn btn-primary btn-sm"><span class="ace-icon fa fa-search icon-on-right bigger-110"></span>查询</button>
								</span>
							</div>
						</div>


                        <div class="row">
                            <div class="col-sm-12" style="overflow-x:auto">
                                <table id="xmgl-project-list"></table>
                                <div id="xmgl-project-list-pager"></div>
                            </div>
                        </div>
						
						
												
                    </div>
					
					<div class="col-sm-12">
						<!-- 模态框（Modal） -->
						<div class="modal fade bs-example-modal-lg" id="projectDetailModal" tabindex="-1" role="dialog" data-backdrop="true" data-keyboard="false" aria-labelledby="pro_detail_title_id" aria-hidden="true">
							<div class="modal-dialog modal-lg" >
								
								<div class="modal-content" style="height: 600px;overflow: auto;">
									<div class="modal-header hide">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
										</button>
									</div>
									<div class="modal-body center " style="overflow: auto;">
										<div style="clear:both"></div>
										<div style="height:400px;">
											<div class="fp-loading">
											 <i class="fa fa-spinner fa-pulse fa-3x"></i>
											 <p>数据加载中，请耐心等待</p>
											</div>
										</div>
									</div>
									<div class="modal-footer hide">
										
									</div>
								</div><!-- /.modal-content -->
							</div><!-- /.modal -->
						</div>
					</div>	
                <div/>
            </div>
        </div><!-- /.page-content -->
    </div>
</div>
#parse('base/footer.html')
<script>
    var projectType = '';
    jQuery(function ($) {
        menuActive(2);
        $("#projectSearchBtn").on('click',function () {
        	console.log("projectSearchBtn click");
            jQuery("#xmgl-project-list").jqGrid('setGridParam',{
				datatype:'json',
				mtype : "POST",
				postData:{'projectName':$("#form-field-project-name").val(),
					'projectType':$("#form-field-project-type  option:selected").val()
				}, //发送数据
				page:1
			}).trigger("reloadGrid");
        });

        
        $("#projectAddBtn_old").on('click',function () {
        	console.log("projectAddBtn click");
        	//打开模态窗口
    		//console.log("清空模态详情");
    		$('#projectDetailModal').children().remove(); 
    		//console.log("显示加载信息...");
    		$('#projectDetailModal').append('<div class="modal-dialog modal-lg " ><div class="modal-content" style="height: 600px;overflow: auto;"><div class="modal-header hide"></div><div class="modal-body center " ><div style="clear:both"></div><div style="height:400px;"><div class="fp-loading"><i class="fa fa-spinner fa-pulse fa-3x"></i><p>数据加载中，请耐心等待</p></div></div></div><div class="modal-footer hide"></div></div></div>'); 
    		//console.log("加载模态详情");
    		$('#projectDetailModal').modal({keyboard:false,backdrop:true,remote:"$!webPath/basicData/projectDetail?action=add"});
        	
        });
        
        $("#projectAddBtn").on('click',function () {
        	parent.frames[0].location.href  = "$!webPath/basicData/projectDetail?action=add"        	
        });
        
    });
</script>
<!-- 项目列表 -->
<script type="text/javascript">
    function reloadGridData() {
		console.log("reloadGridData...");
        jQuery("#xmgl-project-list").jqGrid('setGridParam',{
            datatype:'json',
			mtype : "POST",
            postData:{'projectName':$("#form-field-project-name").val(),
                'projectType':$("#form-field-project-type  option:selected").val()
			}, //发送数据
            page:1
        }).trigger("reloadGrid");
    }
	
	var parentBodyHeight = $('#left-gov-tree', window.parent.document).height()||800;
    //var pkh_parent_column = $("#xmgl-project-list").closest('[class*="col-"]').closest('h4');
    var widget_header = $(".fpxmList");
	    //resize to fit page size
    $(window).on('resize.jqGrid', function () {
        $("#xmgl-project-list").jqGrid( 'setGridWidth', widget_header.width()-24 );
    });
    function detailClick_pro_old(projectId,editRowId){
        //window.location.href = ("$!webPath/fpxm/detail?projectId="+projectId);
		//打开模态窗口
		//console.log("清空模态详情");
		$('#projectDetailModal').children().remove(); 
		//console.log("显示加载信息...");
		$('#projectDetailModal').append('<div class="modal-dialog modal-lg " ><div class="modal-content" style="height: 600px;overflow: auto;"><div class="modal-header hide"></div><div class="modal-body center " ><div style="clear:both"></div><div style="height:400px;"><div class="fp-loading"><i class="fa fa-spinner fa-pulse fa-3x"></i><p>数据加载中，请耐心等待</p></div></div></div><div class="modal-footer hide"></div></div></div>'); 
		//console.log("加载模态详情");
		$('#projectDetailModal').modal({keyboard:false,backdrop:true,remote:"$!webPath/basicData/projectDetail?action=update&projectId="+projectId+"&editRowId="+editRowId});
    };
	
	function detailClick_pro(projectId,editRowId){
		parent.frames[0].location.href  = "$!webPath/basicData/projectDetail?action=update&projectId="+projectId; 
    };
	
	
    //初始化模态窗口
    jQuery(function($) {
		//v2
		$("#projectDetailModal").on("hidden", function() {  
			$(this).removeData("modal");  
			console.log("projectDetailModal hidden ");
			
		});  
		//v3
		$("#projectDetailModal").on("hidden.bs.modal", function() {  
			$(this).removeData("bs.modal");
			/*modal页面加载$()错误,由于移除缓存时加载到<span style="color: rgb(51, 51, 255);"><div class="modal-content"></div></span>未移除的数据，手动移除加载的内容*/
			$(this).find(".modal-content").children().remove(); 
			console.log("projectDetailModal hidden.bs.moda ");
		}); 
	});
	
    $("#xmgl-project-list").jqGrid({
        url : '$!webPath/basicData/qryProjectByPage',
        datatype : "json",
		mtype : "POST",
        height : parentBodyHeight-160,
        shrinkToFit:false,  
		autoScroll: true, 
        //autowidth: true,
        colNames : [ '操作', '项目编号','项目名称','项目分类','项目子类型','总投资','计划投资','预计收益','开始日期','结束日期','计划年月','项目说明','项目状态','部门领导','责任部门','项目责任人','扶贫办责任人'],
        colModel : [
            //{name : 'xh',index : 'xh',width : 50},
            {name : 'myac',index : '', width:80, fixed:true, sortable:false, resize:false,
//								formatter:'actions',
                formatter: function (cellvalue, options, rowObject) {
                    var detail='<div style="cursor: pointer;">';
                    detail += '<i class="normal-icon ace-icon block-inherit blue " onclick="detailClick_pro(' + rowObject.projectId +',' +options.rowId +')">编辑</i>';
                    detail += '</div>';
                    return detail;
                }

            },
            {name : 'projectCode',index : 'projectCode',width:95,sortable : false},
            {name : 'projectName',index : 'projectName',width:200,sortable : false},
            {name : 'projectTypeName',index : 'projectTypeName',width:95,sortable : false},
            {name : 'projectSubTypeName',index : 'projectSubTypeName',width:95,sortable : false},
            {name : 'totalInvest',index : 'totalInvest',width:80,sortable : false},
            {name : 'planInvest',index : 'planInvest',width:80,sortable : false},
            {name : 'estimatedIncome',index : 'estimatedIncome',width:80,sortable : false},
            {name : 'beginDate',index : 'beginDate',width:90,sortable : false,
				formatter: function (cellvalue, options, rowObject) {
						return cellvalue.slice(0,10);
				}
			},
            {name : 'endDate',index : 'endDate',width:90,sortable : false,
				formatter: function (cellvalue, options, rowObject) {
						return cellvalue.slice(0,10);
				}
			},
			{name : 'planDate',index : 'planDate',width:90,sortable : false,
				formatter: function (cellvalue, options, rowObject) {
						return cellvalue.slice(0,10);
				}
			},
			{name : 'projectDesc',index : 'projectDesc',width:150,sortable : false},
			{name : 'stateName',index : 'stateName',width:95,sortable : false},
			{name : 'cityLeader',index : 'cityLeader',width:95,sortable : false},
			{name : 'respDepartment',index : 'respDepartment',width:95,sortable : false},
			{name : 'respStaff',index : 'respStaff',width:95,sortable : false},
			{name : 'povertyStaff',index : 'povertyStaff',width:95,sortable : false}
            
        ],
        jsonReader : {
            root : "resultList",
            page : "page",
            total : "totalPages",
            records : "totalRecords",
            rows : "resultList"
        },
        rowNum:20,
        rowList:[10,20,50,100],
        pager: '#xmgl-project-list-pager',
        viewrecords : true,
        loadComplete : function() {
			var table = this;
			setTimeout(function(){
				styleCheckbox(table);
				
				updateActionIcons(table);
				updatePagerIcons(table);
				enableTooltips(table);
			}, 0); 

			$(table).siblings(".norecords").remove(); 
			var rowNum = parseInt($(table).getGridParam("records"), 10);   
			if (rowNum <= 0) {   
				$(table).parent().append("<div  class=\"norecords\">没有数据...</div>");
				$(table).siblings(".norecords").show(); 								
			} 
        },

        multiselect : false
    });
    
    $("#xmgl-project-list").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" });
</script>
</body>
</html>
